﻿namespace CodeContrib
{
	public class RandomDecimal : IRandom<decimal>
	{
		private readonly decimal _maximumValue;
		private readonly decimal _minimumValue;

		public decimal MaximumValue
		{
			get { return _maximumValue; }
		}

		public decimal MinimumValue
		{
			get { return _minimumValue; }
		}

		public RandomDecimal(decimal minValue = decimal.MinValue, decimal maxValue = decimal.MaxValue)
		{
			_maximumValue = maxValue;
			_minimumValue = minValue;
		}

		public decimal Next()
		{
			var _randomBoolean = new RandomBoolean();
			var _randomInteger = new RandomInteger();
			var _randomScale = new RandomInteger(0, 29);

			var scale = (byte)_randomScale.Next();
			var sign = _randomBoolean.Next();

			return new decimal(_randomInteger.Next(), _randomInteger.Next(), _randomInteger.Next(), sign, scale);
		}
	}
}